<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>4.使用对象创建正则表达式</title>
    </head>
    <body>
        <div class="content">
            houden123ren123.com
        </div>
        <script type="text/javascript">
            // let hd = "houdenren.comn";
            // let a = "\\d"
            // let reg = new RegExp(a, 'g');
            // console.log(reg.test(hd))
            
            
            let con=prompt("请输入要检测的内容，支持正则表达式");
            let reg=new RegExp(con,'g');
            let div=document.querySelector('div');
            div.innerHTML=div.innerHTML.replace(reg,search=>{
                return `<span style="color:red;">${search}</span>`
            })
            console.log(con)
        </script>
    </body>
</html>
